package com.wj.rpsm.admin.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wj.rpsm.admin.mapper.BuildingMapper;
import com.wj.rpsm.admin.mapper.FloorMapper;
import com.wj.rpsm.admin.pojo.Floor;
import com.wj.rpsm.admin.pojo.PageResult;
import com.wj.rpsm.admin.service.FloorService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author WeiJin
 * @version 1.0
 */
@Service
public class FloorServiceImpl implements FloorService {

    @Autowired
    private FloorMapper floorMapper;

    @Autowired
    private BuildingMapper buildingMapper;



    @Override
    public PageResult<Floor> pageOfFloor(Integer current, Integer size, String number) {
        PageHelper.startPage(current,size);
        Page<Floor> floors = floorMapper.findAllFloor(number);
        floors.stream().forEach(floor ->
                floor.setBuilding_name(buildingMapper.queryBuId(floor.getBelong_building())));
        return PageResult.restPage(floors);
    }
}
